package com.centling.smartSealForPhone.utils;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.TextView;
import android.widget.Toast;

import com.centling.smartSealForPhone.R;
import com.centling.smartSealForPhone.application.SmartSeal;

/**
 * 当字数达到某个值时进行提示
 * @author fionera
 */
public class TextLengthWatch implements TextWatcher {
    private int number;

    /**
     * @param number 限制的字数
     */
    public TextLengthWatch(int number) {
        this.number = number;

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        if (s.toString().length() >= number) {
            Toast.makeText(SmartSeal.getInstance(), "最大字数为" + number, Toast.LENGTH_LONG).show();
        }
    }

    @Override
    public void afterTextChanged(Editable s) {
    }
}